// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.query.properties.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.util.Arrays;
import java.util.HashSet;

import com.yahoo.processing.request.properties.PropertyMap;
import org.junit.Test;

import com.yahoo.search.query.properties.SubProperties;

/**
 * @author <a href="mailto:arnebef@yahoo-inc.com">Arne Bergene Fossaa</a>
 */
public class SubPropertiesTestCase {

    @Test
    public void testSubProperties() {
        PropertyMap map = new PropertyMap() {{
            set("a.e","1");
            set("a.f",2);
            set("b.e","3");
            set("f",3);
            set("e","2");
            set("d","a");
        }};

        SubProperties sub = new SubProperties("a", map);
        assertEquals("1",sub.get("e"));
        assertEquals(2,sub.get("f"));
        assertNull(sub.get("d"));
        assertEquals(new HashSet<>(Arrays.asList("e", "f")), sub.listProperties("").keySet());
    }

}
